#!/bin/tcsh
#
#  This script runs NWChem on mnemosyne
#
module load mpich
module load nwchem/6.5
#
setenv NWCHEM_PROCS 8
setenv NWCHEM_MEMORY "1200 mb"
setenv NWCHEM_SCRATCH /home/mark/nwchem/scratch
#
set procid=`echo $$`
setenv JOBNAME `ps -p $procid | grep $procid | awk '{print $4}'`
setenv NWCHEM_ROOT `echo $JOBNAME | awk -F_ '{print $1}'`
setenv NWCHEM_SUFFIX `echo $JOBNAME | awk -F_ '{print $2}'`
mkdir $NWCHEM_SCRATCH/$procid
#
# Build the input file
#
cat << finis > $JOBNAME.nw
title "B12 LDA/20Ry - constant energy annealing example"

start  $NWCHEM_ROOT
permanent_dir $cwd
scratch_dir $NWCHEM_SCRATCH/$procid
memory $NWCHEM_MEMORY
ecce_print $JOBNAME.ecce

charge 0

#### icosahedral structure ####
geometry
B 1.06848703 -1.06977718 -0.27191204
B -0.41738004 -1.54046760 0.30786278
B 1.54044867 0.41755176 0.31097113
B -1.53464475 -0.41595403 -0.30802728
B 0.41455946 1.53816406 -0.30497372
B -1.06506013 1.06638042 0.26996858
B 0.69163266 -0.69066193 1.27228704
B -0.26229140 -0.90393650 -1.22051191
B 0.89747884 0.25958856 -1.21386685
B -0.69798902 0.69567491 -1.28227908
B 0.26356093 0.90344215 1.22217740
B -0.89880225 -0.26000463 1.21830395
end

nwpw
   simulation_cell
      boundary_conditions aperiodic
      SC 20.0
   end
   cutoff 10.0
   lmbfgs
   Car-Parrinello
      fake_mass 500.0
      time_step 5.0
      loop 10 100
      scaling 1.0 2.0
      emotion_filename b12.00.emotion
      xyz_filename     b12.00.xyz
   end
end
task pspw energy

set cpmd:init_velocities_temperature 300.0
task pspw car-parrinello


unset cpmd:init_velocities_temperature
task pspw car-parrinello
task pspw car-parrinello
task pspw energy
task pspw car-parrinello


nwpw
   Car-Parrinello
      scaling 0.99 0.99
      emotion_filename b12.01.emotion
      xyz_filename     b12.01.xyz
   end
end
task pspw energy
task pspw car-parrinello
task pspw car-parrinello
task pspw car-parrinello
finis
#
#   Run the job
#
mpirun -np $NWCHEM_PROCS nwchem $JOBNAME.nw >& $JOBNAME.nwo
#
#   Clean up scratch directory
rm -rf $NWCHEM_SCRATCH/$procid
